﻿@{
    Layout = "~/Views/Shared/_Layout_Easyui.cshtml";
}
<div id="main_index_layout" class="easyui-layout">
    @* <div data-options="region:'north'" style="height: 30px">
            @{
                Html.RenderPartial("North");
            }
        </div>
        <div data-options="region:'south',split:true,collapsed:true" title="常用备注" style="height: 200px;">
            @{
                Html.RenderPartial("South");
            }
        </div>
        <div data-options="region:'east',split:true,collapsed:true" title="每日提示" style="width: 180px;">
            @{
                Html.RenderPartial("East");
            }
        </div>*@
    <div data-options="region:'west',split:true" title="功能导航" style="width: 200px;">
        <div id="main_index_accordion">
            <div title="工作" data-options="selected:true">
                <ul id="main_index_tree" class="easyui-tree"></ul>
            </div>
        </div>
    </div>
    <div data-options="region:'center'">
        <div id="main_index_tabs">
            <div title="首页" style="overflow: hidden">
                <iframe name="content" src="@Url.Action("Default", "Home")" scrolling="yes" width="100%" height="100%" frameborder="0"></iframe>
            </div>
        </div>
    </div>
</div>
@section Scripts
{
    <script type="text/javascript">
        Oneworks.CreatePage('MainWest', {
            settings: {
                treeurl: '/Models/tree.json'
            },
            controls: {
                layout: $('#main_index_layout'),
                accorion: $('#main_index_accordion'),
                tree: $('#main_index_tree'),
                tabs: $('#main_index_tabs')
            },
            events: {
                onClickTree: function (node) {
                    var that = Oneworks.page['MainWest'],
                        controls = that.controls,
                        tree = controls.tree,
                        tabs = controls.tabs,
                        leaf = tree.tree('isLeaf', node.target),
                        istab = tabs.tabs('exists', node.text);
                    if (leaf && !istab) {
                        if (node.attributes) {
                            if (node.attributes.target === 'iframe') {
                                tabs.tabs('add', {
                                    id: node.id,
                                    title: node.text,
                                    content: '<iframe  scrolling="yes" frameborder="0"  src="' + node.attributes.href + '" style="width:100%;height:99%;"></iframe>',
                                    closable: true
                                });
                            } else {
                                tabs.tabs('add', {
                                    id: node.id,
                                    title: node.text,
                                    href: node.attributes.href,
                                    closable: true
                                });
                            }
                        }
                    } else {
                        if (istab) {
                            tabs.tabs('select', node.text);
                        }
                    }
                }
            }
        }, function () {
            var that = this,
              controls = that.controls,
              settings = that.settings,
              events = that.events;
            controls.init = function () {
                controls.layout.layout({
                    fit: true
                });
                controls.accorion.accordion({
                    fit: true,
                    border: false
                });
                controls.tabs.tabs({
                    fit: true,
                    border: false,
                    plain: true
                });
                controls.tree.tree({
                    method: 'GET',
                    url: settings.treeurl,
                    onClick: function (node) {
                        console.log(node);
                        events.onClickTree(node);
                    }
                });
            };
            controls.init();
        });

    </script>
}



